Skid spills some source...
We begin with the smallest monkey program.
Function Main() Print "Hello"EndTo learn more about the Main entry point of a program make sure you read the Programs and Declarations section of the Language reference.
We now build a mojo App which we call Game (in monkey class names are typically capitalized).
Import mojoClass Game Extends App Method OnCreate() Print "hello" End EndFunction Main() New Game()EndA mojo App is used to provide us methods of input, graphics and sound. The framework above creates a single App using the Game class definition.
With our game object defined we extend the basic Update and Render parts of the app.
The minimum requirements for an animating monkey application are an App implementing the methods:
Import mojoClass Game Extends App ' radial sprial with axis aligned phase Function DrawSpiral(clock) Local w=DeviceWidth/2 For Local i#=0 Until w*1.5 Step .2 Local x#,y# x=w+i*Sin(i*3+clock) y=w+i*Cos(i*2+clock) DrawPoint x,y Next End Field updateCount Method OnCreate() Print "spiral" SetUpdateRate 60 End Method OnUpdate() updateCount+=1 End Method OnRender() Cls DrawSpiral updateCount DrawSpiral updateCount*1.1 End EndFunction Main() New Game()EndEach spiral drawn by the program begins at the middle of the screen and spirals out using the Maths functions Sin and Cos.
Here is the final application: